
App({
    data: {
        userInfo: {
            userId: 2,
            nickname: "关羽",
            avatar: "/static/image/first.png"
        }
    },
    onLaunch() {
        // 异步清理本地数据缓存
        wx.clearStorage()

        /**
         * 存在获取 openid 失败的情况
         * */
        wx.login({
            success: res => {
                wx.request({
                    method: 'POST',
                    url: 'http://120.24.97.106:8889/miniUserInfo/login',
                    data: {
                        js_code: res.code
                    },
                    success(res_login) {
                        let resData = res_login.data
                        console.log(resData)
                        if (resData.code === 200) {
                            wx.setStorage({key: 'openid', data: resData.data.openid})
                            wx.setStorage({
                                key: 'getOpenidEd',
                                data: true
                            })
                        } else {
                            console.log("获取openid失败")
                        }
                    }
                })
            }
        })
    }


})
